#ifndef RLCONN_H
#define RLCONN_H

#include "connect.h"

class RouletteGuts;
class RouletteRound;

#ifdef FORCED_ROULETTE
class RouletteForcedGuts;
#endif

class RouletteConnection : public Connection
{
	public:
		RouletteConnection(Server*, SOCKET client);
		~RouletteConnection();

		void msgStart();
		void msgAdd(uint8 Byte);
		void msgAdd(int32 SignedLong);
		uint8* msgGetBuf();
		void msgReleaseBuf(int32 Amt);
		void msgEnd();

	protected:
		bool8	getResponse();
		void	handleLogin(int32 len);

		void	sendStopMsg();

		uint8	getTableID();
		String  getPid();

		bool8	parseCasinoLogin(int32, int32*);
		bool8	parseUnicodeCasinoLogin(int32, int32*);

		void	removeCasinoSpecific();

		int32	encode(uint8*, uint8*, int32);
		int32	decode(uint8*, uint8*, int32);

		int32	msgRemove(uint8*, uint8*);
		int32	msgRemove(uint8*, int32*);

		bool8	trackGetBalance(int32 *);
		int32	trackAdjustBalance(int32);	// + increases  - decreases
		bool8	trackSpin(uint8, int32, RouletteRound*, int32*);
		bool8	trackGetPlayerLimits(int32*, int32*, int32*, int32*, int32*, int32*);
		void	trackaddBadPacket(int32 error_reason, char MessageType, char *msgbuf, int32 msglen);
		int32	trackValidateLogin();
		int32	trackValidateSession();

		// CSN-7075: New Authentication
		void	trackLogoutSession();

		void	allocateXMLTranslator( XMLTranslator** target );

	protected:
		int32 loggedOn;
		RouletteGuts* guts;

#ifdef FORCED_ROULETTE
		RouletteForcedGuts* forcedGuts;
		bool8 forcedSpinsLoaded;
#endif
		void* casinoSpecific;
		int32 minInsideBet, maxInsideBet, minOutsideBet, maxOutsideBet, maxSingleInsideBet;
		int32 compFactor;
		int32 msglen;
		uint8 msgbuf[1024];

	// [AO 2008-01-16] Refactoring for HA
	private:
		bool ValidateSession();
};

#endif
